Ext.define('AmpleHarvest.views.geData.main',
{
	extend			: 'Ext.panel.Panel',
	alias			: 'widget.ampleharvest-views-gesearch-main',
	title			: 'GROUNDEFFECT XML data',
	requires		:
	[
	 		"AmpleHarvest.objects.results.results"
	],
	anchor			: '100% 100%',
	layout			: 'border',
	m_str_path			: '/tpds_services/procurement-rest/procurement/ext/ge/raw/',
	tbar: [
	       { 
	    	   xtype	: 'button', 
	    	   text		: 'Download Raw XML',
	    	   handler	: function(object) {
	    		   var obj_view = object.up('ampleharvest-views-gesearch-main');
	    		   location = obj_view.m_str_path+obj_view.m_str_id+'/download';
	    	   }
	    	}
	     ],
	listeners		:
	{
	},
	
	initComponent	: function()
	{
//		console.log(this.m_str_data_source)
		this.m_obj_Content = Ext.create(
				"AmpleHarvest.objects.content.cContent",
				{
					flex				: 1,
					region 				: "center",
					str_data_source		: this.m_str_path+this.m_str_id,
					verifyData			: function (obj_response)
					{
						console.log('verify this');
						console.log(obj_response);
						if(!obj_response.success) return false;
						if(!obj_response.success == true) return false;
						if(!obj_response.data) return false;
						if(!obj_response.data.content) return false;

						return true;
					},
					transformData 		: function(object)
					{
//						var display = object.data.content.replace(/></g, ">\n<");
//						object.data.content = '<xmp>'+display+'</xmp>';
						var obj_return = { 
								content 		: object.data.content,
								type			: object.data.type
							}
						return obj_return;
					},
					writeContent		: function(obj_data)
					{
						this.update(obj_data.content);
					}
				}
		);


		this.items =
		[
				this.m_obj_Content
		]
		this.callParent();

	}
});


